namespace QMVnSoft.Lists
{
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Drawing;

    public class FormDmSpLister : FormListLister
    {
        private IContainer components;

        public FormDmSpLister()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0x2bd, 0x10a);
            base.LocalFieldName = "MA_SP";
            base.LocalTableName = "DMSP";
            base.Name = "FormDmSpLister";
            base.OrderFieldNames = "SP_CT DESC, LOAI_SP DESC, MA_SP_ME, MA_SP";
            this.Text = "Danh mục sản phẩm, công trình";
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public override bool OnAdd()
        {
            base.LocalFormEditor = new FormDmSpEditor();
            return base.OnAdd();
        }

        public override bool OnEdit()
        {
            base.LocalFormEditor = new FormDmSpEditor();
            return base.OnEdit();
        }

        public override void OnFillData()
        {
            object[][] objArray = new object[6][];
            object[] objArray2 = new object[4];
            objArray2[0] = "Ma_Sp";
            objArray2[1] = "Mã sản phẩm\nCông trình";
            objArray2[2] = "C";
            objArray[0] = objArray2;
            object[] objArray3 = new object[4];
            objArray3[0] = "Ten_Sp";
            objArray3[1] = "Tên sản phẩm\nCông trình";
            objArray3[2] = "C";
            objArray[1] = objArray3;
            object[] objArray4 = new object[4];
            objArray4[0] = "Dvt";
            objArray4[1] = "Đvt";
            objArray4[2] = "C";
            objArray[2] = objArray4;
            object[] objArray5 = new object[4];
            objArray5[0] = "Loai_Sp";
            objArray5[1] = "Loại";
            objArray5[2] = "C";
            objArray[3] = objArray5;
            object[] objArray6 = new object[4];
            objArray6[0] = "Ma_Sp_Me";
            objArray6[1] = "Công đoạn\nCông trình";
            objArray6[2] = "C";
            objArray[4] = objArray6;
            object[] objArray7 = new object[4];
            objArray7[0] = "SP_CT";
            objArray7[1] = "Sản phẩm (S)\nCông trình (C)";
            objArray7[2] = "C";
            objArray[5] = objArray7;
            base.ColNames = objArray;
            base.OnFillData();
        }

        public override void OnRefresh()
        {
            base.LocalDataSet = new DmSpDataAccess().GetDataSet();
            base.OnRefresh();
        }

        protected override void OnShowChildForm()
        {
            if (this.IsContainChilds)
            {
                FormDmDmSpLister lister = new FormDmDmSpLister(this);
                lister.CurrentCode = base.ChildItemCode;
                base.ChildFormLister = lister;
                lister.ShowDialog();
            }
        }

        protected override bool IsContainChilds
        {
            get
            {
                return ((base.LocalCurrentRow != null) && base.LocalCurrentRow["Loai_Sp"].Equals("C"));
            }
        }
    }
}

